package com.marvels.product.productmanage.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.product.param.dto.McptProduct;
import com.marvels.product.param.service.ProductService;
import com.marvels.product.productmanage.Feign.Financial;
import com.marvels.product.productmanage.dto.FundDTO;
import com.marvels.product.productmanage.dto.McptChannelDto;
import com.marvels.product.productmanage.dto.McptProductFundRelationDto;
import com.marvels.product.productmanage.dto.McptProductMappedDto;
import com.marvels.product.productmanage.dto.McptProductTypeChannelDto;
import com.marvels.product.productmanage.dto.McptProductTypeDto;
import com.marvels.product.productmanage.dto.McptProductTypeTermDto;
import com.marvels.product.productmanage.dto.McptProductVersionDto;
import com.marvels.product.productmanage.dto.OrganizationInfoDTO;
import com.marvels.product.productmanage.service.ProductFundRelationApi;
import com.marvels.product.productmanage.service.ProductTypeService;

/**
 * @author 娄凯琦
 *
 */
/**
 * @author 娄凯琦
 * @date 2018年4月14日  
 */
@RestController
@RequestMapping("product/mcpt/service")
public class ProductServiceController {
	@Autowired
	private ProductTypeService productTypeService;

	@Autowired
	private Financial financial;

	@Autowired
	private ProductFundRelationApi relationApi;
	@Autowired
	private ProductService productService;

	/**
	 * 首页信息展示
	 * 
	 * @param mcptChannelDto
	 * @return
	 */
	@RequestMapping("/queryOnlineProduct")
	@ResponseBody
	public MarvelsResultDTO getHomeInfo() {
		try {
			MarvelsLogUtil.getInstance().info("getHomeInfo the method start ==>");
			Map<String, Object> rtnMap = productTypeService.getHomeInfo();
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),
					rtnMap);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),
					e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),
					e.getMessage());
		}
	}
	
	/**
	 * 查询产品大类
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月10日
	 * @param qp
	 * @return
	 */
	@RequestMapping("/searchProduct")
	@ResponseBody
	public MarvelsResultDTO getProduct(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto) {
		try {
			MarvelsLogUtil.getInstance().info("getProduct the method start ==>" + mcptProducTypeDto);
			List<McptProductTypeDto> list = productTypeService.queryProduct(mcptProducTypeDto);
			MarvelsResultDTO dto = MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), list);
			return dto;
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	/**
	 * 获取所有下拉框选项的值
	 * @return
	 * @throws MarvelsBusinessException
	 */
	@RequestMapping("getAllSelector")
	@ResponseBody
	public MarvelsResultDTO getAllSelector() throws MarvelsBusinessException{
		try {
			Map<String,Object> map = productTypeService.getAllSelector();
			MarvelsResultDTO dto = MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), map);
			return dto;
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	/**
	 * 获取小类版本
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月11日
	 * @param qp
	 * @return
	 */
	@RequestMapping("/searchVersion")
	public MarvelsResultDTO getVersion(@RequestBody(required = false) McptProductVersionDto mcptProductVersionDto) {
		try {
			MarvelsLogUtil.getInstance().info("getVersion the method start ==>" + mcptProductVersionDto);
			MarvelsResultDTO dto = MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), productTypeService.queryVersion(mcptProductVersionDto));
			return dto;
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**
	 * 停用或者启用版本
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月11日
	 * @param qp
	 * @returnproductDelete
	 */
	@RequestMapping("/productUpdate")
	public MarvelsResultDTO productUpdate(@RequestBody(required = false) McptProductVersionDto mcptProductVersionDto) {
		try {
			MarvelsLogUtil.getInstance().info("productUpdate the method start ==>" + mcptProductVersionDto);
			productTypeService.productUpdate(mcptProductVersionDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"修改成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**删除产品大类
	 * @author 娄凯琦
	 * @date 2018年4月14日  
	 * @param mcptProductVersionDto
	 * @return
	 */
	@RequestMapping("/productDelete")
	public MarvelsResultDTO productDelete(@RequestBody(required = false) McptProductVersionDto mcptProductVersionDto) {
		try {
			MarvelsLogUtil.getInstance().info("productDelete the method start ==>" + mcptProductVersionDto);
			productTypeService.productDelete(mcptProductVersionDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**
	 * 添加产品大类
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月10日
	 * @param map
	 * @param req
	 * @return
	 */
	@RequestMapping("/productInsert")
	public MarvelsResultDTO productInsert(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto,HttpServletRequest req) {
		try {
			MarvelsLogUtil.getInstance().info("productInsert the method start ===>" + mcptProducTypeDto);
			productTypeService.productInsert(mcptProducTypeDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"添加成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**
	 * 查询所有的渠道
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月10日
	 * @param map
	 * @return
	 */
	@RequestMapping("/searchChannel")
	public MarvelsResultDTO searchChannel(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto) {
		try {
			MarvelsLogUtil.getInstance().info("searchChannel the method start ===>" + mcptProducTypeDto);
			List<McptChannelDto> list = productTypeService.queryChannel(mcptProducTypeDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**
	 * 查询产品大类所有的渠道和期限
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月10日
	 * @param map
	 * @return
	 */
	@RequestMapping("/searchChannelAndTerm")
	public MarvelsResultDTO searchChannelAndTerm(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto) {
		try {
			MarvelsLogUtil.getInstance().info("searchChannelAndTerm the method start ===>" + mcptProducTypeDto);
			List<McptProductTypeChannelDto> channelList = productTypeService.queryChannelByProductCode(mcptProducTypeDto);
			List<McptProductTypeTermDto> termList = productTypeService.queryTermByProductCode(mcptProducTypeDto);
			Map<String, Object> ctMap = new HashMap<String, Object>();
			ctMap.put("channelList", channelList);
			ctMap.put("termList", termList);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),ctMap);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	
	@RequestMapping("/selectByChannelCode")
	public MarvelsResultDTO selectByChannelCode(@RequestBody(required = false) McptProductTypeChannelDto mcptProductTypeChannelDto) {
		try {
			List<McptProductTypeChannelDto> channelList = productTypeService.selectByChannelCode(mcptProductTypeChannelDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),channelList);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	

	/**
	 * 产品大类编辑提交
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月10日
	 * @param map
	 * @return
	 */
	@RequestMapping("/editConfirm")
	public MarvelsResultDTO editConfirm(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto) {
		try {
			MarvelsLogUtil.getInstance().info("editConfirm the method start ===>" + mcptProducTypeDto);
			productTypeService.editConfirm(mcptProducTypeDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"保存成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	// public MarvelsResultDTO searchProductVersion(@RequestBody(required=false)
	// Map<String,Object> map){
	// return null;
	// }

	/**
	 * 生成版本和产品小类
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月10日
	 * @param map
	 * @return
	 */
	@RequestMapping("/generateVersion")
	public MarvelsResultDTO generateVersion(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto) {
		try {
			MarvelsLogUtil.getInstance().info("generateVersion the method start ===>" + mcptProducTypeDto);
			productTypeService.generateVersion(mcptProducTypeDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**
	 * 获取产品大类对应的所有版本号
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月10日
	 * @param map
	 * @return
	 */
	@RequestMapping("/searchProductVersion")
	public MarvelsResultDTO searchProductVersion(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto) {
		try {
			MarvelsLogUtil.getInstance().info("searchProductVersion the method start ===>" + mcptProducTypeDto);
			List<McptProductTypeDto> list = productTypeService.queryProductVersion(mcptProducTypeDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**
	 * 根据版本号查询所有产品小类
	 * 
	 * @author 娄凯琦
	 * @date 2018年4月11日
	 * @param map
	 * @return
	 */
	@RequestMapping("/searchByVersion")
	public MarvelsResultDTO searchByVersion(@RequestBody(required = false) McptProductTypeDto mcptProducTypeDto) {
		try {
			MarvelsLogUtil.getInstance().info("searchByVersion the method start ===>" + mcptProducTypeDto);
			List<McptProduct> list = productTypeService.queryByVersion(mcptProducTypeDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	
	/**
	 * 通过大类、渠道、期数、评级等信息查询产品小类
	 * @author 娄凯琦
	 * @date 2018年4月11日
	 * @param map
	 * @return
	 */
	@RequestMapping("/searchByParams")
	public MarvelsResultDTO searchByParams(@RequestBody McptProductMappedDto mapped) {
		try { 
			List<McptProduct> list = productService.searchAllByParams(mapped);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	@RequestMapping("/product/mcpt/get")
	public MarvelsResultDTO getFund() {
		FundDTO fun = new FundDTO();
		return financial.listCMPT(fun);
	}

	/**新增产品映射资金源
	 * @author 娄凯琦
	 * @date 2018年4月14日  
	 * @param mcptProductFundRelationDto
	 * @return
	 */
	@RequestMapping("/saveProductAndFund")
	public MarvelsResultDTO saveProductAndFund(@RequestBody(required = false) McptProductFundRelationDto mcptProductFundRelationDto) {
		try {
			MarvelsLogUtil.getInstance().info("saveProductAndFund the method start ===>" + mcptProductFundRelationDto);
			productTypeService.saveProductFund(mcptProductFundRelationDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"保存成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**查询产品映射资金源
	 * @author 娄凯琦
	 * @date 2018年4月14日  
	 * @param mcptProductFundRelationDto
	 * @return
	 */
	@RequestMapping("/searchProductMappingFund")
	@ResponseBody
	public MarvelsResultDTO searchProductMappingFund(@RequestBody(required = false) McptProductFundRelationDto mcptProductFundRelationDto) {
		try {
			MarvelsLogUtil.getInstance().info("searchProductMappingFund the method start ===>" + mcptProductFundRelationDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),productTypeService.queryProductMappingFund(mcptProductFundRelationDto));
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**删除产品映射资金源
	 * @author 娄凯琦
	 * @date 2018年4月14日  
	 * @param mcptProductFundRelationDto
	 * @return
	 */
	@RequestMapping("/removeProductMappingFund")
	@ResponseBody
	public MarvelsResultDTO removeProductMappingFund(@RequestBody(required = false) McptProductFundRelationDto mcptProductFundRelationDto) {
		try {
			MarvelsLogUtil.getInstance().info("removeProductMappingFund the method start ===>" + mcptProductFundRelationDto);
			List<McptProductFundRelationDto> list = productTypeService.removeProductMappingFundById(mcptProductFundRelationDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}

	/**修改产品映射资金源
	 * @author 娄凯琦
	 * @date 2018年4月14日  
	 * @param mcptProductFundRelationDto
	 * @return
	 */
	@RequestMapping("/editProductMappingFund")
	public MarvelsResultDTO editProductMappingFund(@RequestBody(required = false) McptProductFundRelationDto mcptProductFundRelationDto) {
		try {
			MarvelsLogUtil.getInstance().info("editProductMappingFund the method start ===>" + mcptProductFundRelationDto);
			productTypeService.updateProductMappingFundById(mcptProductFundRelationDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"编辑成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	
	
	/**新增产品映射渠道
	 * @author 娄凯琦
	 * @date 2018年4月16日  
	 * @param mcptProductFundRelationDto
	 * @return
	 */
	@RequestMapping("/addproductMapped")
	public MarvelsResultDTO addproductMapped(@RequestBody(required = false) McptProductMappedDto mcptProductMappedDto) {
		try {
			MarvelsLogUtil.getInstance().info("addproductMapped the method start ===>" + mcptProductMappedDto);
			productTypeService.addproductMappedChannel(mcptProductMappedDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(),"添加成功");
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	
	
	
	/**查询产品映射渠道信息
	 * @author 娄凯琦
	 * @date 2018年4月16日  
	 * @param mcptProductMappedDto
	 * @return
	 */
	@RequestMapping("/searchProductMapped")
	public MarvelsResultDTO searchProductMapped(@RequestBody(required = false) McptProductMappedDto mcptProductMappedDto) {
		try {
			MarvelsLogUtil.getInstance().info("searchproductMapped the method start ==>" + mcptProductMappedDto);
			List<McptProductMappedDto> list = productTypeService.searchProductMapped(mcptProductMappedDto);
			MarvelsResultDTO dto = MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), list);
			return dto;
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	
	
	
	/**编辑产品映射资金源
	 * @author 娄凯琦
	 * @date 2018年4月21日  
	 * @param mcptProductMappedDto
	 * @return
	 */
	@RequestMapping("/modifyProductMapped")
	public MarvelsResultDTO modifyProductMapped(@RequestBody(required = false) McptProductMappedDto mcptProductMappedDto) {
		try {
			MarvelsLogUtil.getInstance().info("modifyProductMapped the method start ==>" + mcptProductMappedDto);
			productTypeService.modifyProductMappedChannel(mcptProductMappedDto);
			MarvelsResultDTO dto = MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), "成功");
			return dto;
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	/**
	 * 获取产品映射参数对应的下拉列表
	 * @param mcptProductMappedDto
	 * @return
	 */
	@RequestMapping("findProductMappedSelector")
	@ResponseBody
	public MarvelsResultDTO findProductMappedSelector(@RequestBody(required = false) McptProductMappedDto mcptProductMappedDto){
		try {
			Map<String,Object> reuslt = productTypeService.findProductMappedSelector(mcptProductMappedDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(),reuslt);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	
	
	
	/**
	 * 查询产品映射资金源信息
	 * @param relationDto
	 * @return
	 */
	@RequestMapping("/selectProductFundRelation")
	@ResponseBody
	public List<McptProductFundRelationDto> selectProductFundRelation(@RequestBody(required = false) McptProductFundRelationDto relationDto) {
			return relationApi.selectProductFundRelation(relationDto);
	}
	/**
	 * 获取渠道一、渠道二、团队信息
	 * @param orgDto
	 * @return
	 */
	@RequestMapping("findOrgInfoList")
	@ResponseBody
	public MarvelsResultDTO findOrgInfoList(@RequestBody OrganizationInfoDTO orgDto){
		try {
			List<OrganizationInfoDTO> reuslt = productTypeService.findOrgInfoList(orgDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(),reuslt);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(e.getMessage(), e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), MarvelsErrorCode.FAIL.getDesc(),e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("系统异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), MarvelsErrorCode.ERROR.getDesc(),e.getMessage());
		}
	}
	
}
